package Java编程的逻辑.第八章.泛型;

/**
 * 泛型方法
 */
public class GenericMethod {
    public static <T> int indexOf(T[] arr, T elem) {
        for(int i=0; i<arr.length; i++) {
            if(arr[i].equals(elem)) {
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        System.out.println(indexOf(new Integer[]{1, 2, 3}, 2));
    }
}
